To cause difficulty or make trouble for someone.
During WWII, German troops gave the Allies a hard time in Italy, but eventually the Allies broke through.
To tease, kid or rib someone.
He's usually pretty good-natured when the children give him a hard time about his bald spot.